<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    {include file="public/_head"}
    <title>添加等级</title>
    <style>
        .input-text[type="number"] {
            width: 100%;
        }
    </style>
</head>
<body>
<article class="cl pd-20">
    <form action="" method="post" class="form form-horizontal" id="form-member-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>等级名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="{$data.name|default=''}" placeholder="" id="name" name="name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>级别：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="number" class="input-text" value="{$data.level|default=''}" placeholder="" id="level" name="level">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>所需经验：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="number" class="input-text" value="{$data.integral|default=''}" placeholder="" id="integral" name="integral">
            </div>
        </div>
        <input type="hidden" id="id" value="{$data.id|default=''}">
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="button" onclick="submit1()"
                       value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

<!--_footer 作为公共模版分离出去-->
{include file="public/_footer" /}
<!--/_footer /作为公共模版分离出去-->

<script type="text/javascript">
    function submit1() {
        let name = $('#name').val();
        let level = $('#level').val();
        let integral = $('#integral').val();
        if (!name) {
            $.mag('请填写等级名称');
            return;
        }else if(!level){
            $.mag('请填写级别');
            return;
        }else if(!integral){
            $.mag('请填写所需经验');
            return;
        }
        let data = {
            id: $("#id").val(),
            name: name,
            level: level,
            integral: integral
        };
        $.ajax1(this, '/grade/save', 'post', data, function () {
            $.mag('添加成功', 1, 3000);
            parent.location.href = "/grade/index";
        });
    }
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>